package com.example.tsproject.Controller;

import com.example.tsproject.entity.Posts;
import com.example.tsproject.entity.Videos;
import com.example.tsproject.service.PostsService;
import com.example.tsproject.service.VideosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import  com.example.tsproject.Utils.sql;

import java.util.ArrayList;
import java.util.List;

/**
 * @BelongsProject: t-s-project
 * @BelongsPackage: com.example.tsproject.Controller
 * @Author: YoungDra
 * @CreateTime: 2024/11/24  10:40
 */
@RestController
public class OnlineSqlController {
    @Autowired
    PostsService postsService;
    @Autowired
    VideosService videosService;
    @RequestMapping("/onlineSql1")
    public String onlineSql(String sql1){
        return sql.formatSqlToOneLine(sql1);
    }
    @GetMapping("/onlineSql2")
    public List<Videos> onlineSql2(@RequestParam("sql2") String sql2){
        System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
        System.out.println(sql2);
        List<Videos> ans=new ArrayList<>();
        ans= videosService.onlineSql(sql2);
//        if(sql.isValidQuery(sql2)){
//        }
        return ans;
    }
}
